package com.zcx.base.test.test;

import com.zcx.base.rabitmq.ack.AckSenderService;
import com.zcx.base.test.TestApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestApplication.class) // 指定启动类
public class RabitMq {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Autowired
    private AckSenderService ackSenderService;

    @Test
    public void rabitMqTest() {
        String content = "Date:" + System.currentTimeMillis();
        //发送默认交换机对应的的队列kinson
        rabbitTemplate.convertAndSend("kinson", content);
        try {
            Thread.sleep(60000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }



    @Test
    public void rabitMqAckTest() {
        ackSenderService.send();
        try {
            Thread.sleep(600000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
